
*****************************************************
* Mexico Pollfish Survey            				*
* E1 Survey Experiment      				        *
* Ana López García, Sarah Berens & Barry Maydom 	*
* July 2023                                         *
* 		                            				*
* DATA PREPARATION                                  *
* Pollfish Mexico Survey Dec 31-Jan2nd 21/22        *
*****************************************************

*CHECK 

**set file directory 

use "Data\Surveys 1-12 Pollfish.dta", clear 

**********************
*EXPERIMENT NUMBER 1*
**********************

*********************
***Data Preparation**
*********************
*1. Dependent variables
*2. Independent variables
**2.a Migration-related variables
**2.b Context (US state) variables
**2.c Demographic and socioeconomic variables
**2.d Tax attitudes 
**2.e Political attitudes and behaviour
**2.f Security
**2.g Covid


*************************
*1. Dependent Variables**
*************************
*DV
gen E1_pay_taxes = Q36_eval 
label variable E1_pay_taxes "DV: Willigness to pay higher taxes"
label define E1_pay_taxes 1"Strongly disagree" 2"Disagree" 3"Neither agreee, nor disagree" 4"Agree" 5"Strongly agree", modify
label values E1_pay_taxes E1_pay_taxes
tab E1_pay_taxes

*T1 - Tax instruments 
gen E1_vign1 = Q36_vign1
label define  E1_vign1 0"control" 1"T1_VAT" 2"T1_PIT", modify
label values  E1_vign1  E1_vign1
tab E1_vign1
label variable E1_vign1 "Tax instrument manipulation" 

*T2 - Tax instruments 
gen E1_vign2 = Q36_vign2
label define  E1_vign2 0"control" 1"T2_Health" 2"T2_Roads" 3"T2_Security", modify
label values  E1_vign2  E1_vign2
tab E1_vign2
label variable E1_vign2 "Tax earmarking manipulation" 

*create dummies for balance tables vat vs control
gen e1_vign1_VAT=.
replace e1_vign1_VAT=1 if Q36_vign1==1
replace e1_vign1_VAT=0 if Q36_vign1==0

*create dummies for balance tables PIT vs control
gen e1_vign1_PIT=.
replace e1_vign1_PIT=1 if Q36_vign1==2
replace e1_vign1_PIT=0 if Q36_vign1==0

*Generate seperate DVs for ttest vignette 1
gen E1_pay_taxes_control_vign1=.
replace E1_pay_taxes_control_vign1=E1_pay_taxes if Q36_vign1==0

gen E1_pay_taxes_VAT_vign1=.
replace E1_pay_taxes_VAT_vign1=E1_pay_taxes if Q36_vign1==1

gen E1_pay_taxes_PIT_vign1=.
replace E1_pay_taxes_PIT_vign1=E1_pay_taxes if Q36_vign1==2

*Generate seperate DVs for ttest vignette 2
gen E1_pay_taxes_control_vign2=.
replace E1_pay_taxes_control_vign2=E1_pay_taxes if Q36_vign2==0

gen E1_pay_taxes_health_vign2=.
replace E1_pay_taxes_health_vign2=E1_pay_taxes if Q36_vign2==1

gen E1_pay_taxes_roads_vign2=.
replace E1_pay_taxes_roads_vign2=E1_pay_taxes if Q36_vign2==2

gen E1_pay_taxes_safety_vign2=.
replace E1_pay_taxes_safety_vign2=E1_pay_taxes if Q36_vign2==3


************************
*EFFECT CODING VARIABLES 

igenerate E1_vign1, gen(e1_vign1_effect) coding(effect)
rename e1_vign1_effect2 e1_vign1_VAT_effect
rename e1_vign1_effect3  e1_vign1_PIT_effect

igenerate E1_vign2, gen(e1_vign2_effect) coding(effect)
rename e1_vign2_effect2 e1_vign2_health_effect
rename e1_vign2_effect3 e1_vign2_roads_effect
rename e1_vign2_effect4 e1_vign2_security_effect

label variable e1_vign1_VAT_effect "VAT"
label variable e1_vign1_PIT_effect "Income taxes"

label variable e1_vign2_health_effect "Health"
label variable e1_vign2_roads_effect "Roads"
label variable e1_vign2_security_effect "Security"

***************************
*2. Independent Variables**
***************************

*********************************
*2a. Migration-related Variables*
*********************************
*2a.1 Emigration intentions
*2a.2 Migrant respondents 
*2a.3 Returning migrants 
*2a.4 Remittance receipt
*2a.5 Frequency of communication with migrants abroad
 

*2a.1 Emigration intentions
recode Q28_1 1/2=0 3/4=1, gen(emigration)
label variable emigration "Emigration_intentions"

*2a.2 Migrant respondents 
recode Q2 2=0, gen(migrant)  
label define migrant 0 "Nonmigrant" 1 "Migrant" 
label values migrant migrant
label variable migrant "Migrant household" 

*2a.3 Returning migrants 
gen return = Q11 
label define returning 0 "Nonmigrant" 1 "Returning" 2 "Nonreturning migrant"
label values return returning 
label variable return "Returning vs nonreturning migrant household" 

*Return2 (no distinction among migrants) 
recode Q11 0=0 1=1 2=0, gen(return2)
label define returning2 0 "No return" 1 "Return"
label values return2 returning2 
label variable return2 "Returning migrant household (no distinction among migrants)" 

*2a.4 Remittance receipt (non-recipients vs recipients - no distinction among migrants) 
recode Q6 0=0 2=0, gen(remittances)  
label define remittances 0 "Nonrecipient" 1 "Recipient" 
label values remittances remittances
label variable remittances "Remittance-receiving household (no distinction among migrants)" 

*Economic Remittances  
gen remittances2 = Q6   
label define remittances2 0 "Nonmigrant" 2 "Nonrecipient" 1 "Recipient" 
label values remittances2 remittances2
label variable remittances2 "Remittance-receiving households" 

*2a.5 Frequency of communication with migrants abroad
recode Q5 1/3=1 4/6=0 0=0, gen (communication)
label variable communication "Frequency of communication with migrants abroad"
label define communication 1 "At least once or twice a month" 0 "otherwise" 
label values communication communication 



********************************
*2b. Context (US state) Variables
**2b.a Healthcare access 
**2b.b Welfare access 
**2b.c E-Verify
**2b.d Police-based measures
**2b.e Blue / red states
**2b.f Tax structure
**2b.g Drivers' licenses to undocumented migrants 
**2b.h Covid deaths in the US 
**2b.i Migrants historical origin states - Mexico
**2b.j Migrants historical destination states - USA

****************************************
**2b.a Healthcare access 

*MEDICAID (Borjas 2016) 
*Nonmigrant respondents
gen medicaid2 = 0 if Q2 == 2 
*Migrant respondents living in states that do NOT give Medicaid to unqualified migrants during the 5-year bar 
replace medicaid2 = 1 if Q2 == 1 & (Q4_1 == 1 | Q4_3 == 1 | Q4_12 == 1 | Q4_14 == 1 | Q4_31 == 1 | Q4_36 == 1 | Q4_37 == 1 | Q4_40 == 1 | Q4_41 == 1 | Q4_43 == 1 | Q4_48 == 1 | Q4_50 == 1) 
*Alabama, Arizona, District of Columbia, Idaho, Indiana, New Mexico, Oklahoma, Oregon, South Carolina, South Dakota, Texas, West Virginia, Wyoming
replace medicaid2 = 1 if Q2 == 1 & (Q4_2 == 1 | Q4_4 == 1 | Q4_6 == 1 | Q4_9 == 1 | Q4_10 == 1 | Q4_15 == 1 | Q4_16 == 1 | Q4_17 == 1 | Q4_18 == 1 | Q4_22 == 1 |  Q4_24 == 1 | Q4_25 == 1 | Q4_26 == 1 | Q4_28 == 1 | Q4_29 == 1 | Q4_30 == 1 | Q4_32 == 1 | Q4_33 == 1 |  Q4_34 == 1 | Q4_35 == 1 | Q4_42 == 1 | Q4_44 == 1 | Q4_45 == 1 | Q4_49 == 1 )
*Alaska, Arkansas, Colorado, Florida, Georgia, Iowa, Kansas, Kentucky, Louisiana, Michigan, Mississippi, Missouri, Montana, Nevada, New Hampshire, New Jersey, New York, North Carolina
*North Dakota, Ohio, Tennessee, Utah, Vermont, Wisconsin
*Migrant respondents living in US states that DO give medicaid to unqualified migrants during the 5-year bar 
replace medicaid2 = 2 if medicaid2 == . 
label define medicaid2 0 "Nonmigrant" 1 "No Medicaid" 2 "Medicaid"
label values medicaid2 medicaid2
label variable medicaid2 "Medicaid to unqualified or post-enactment immigrants - Borjas 2016" 
tab medicaid2, gen(medicaid2)

*OBAMACARE 
*Nonmigrant respondents
gen obamacare = 0 if Q2 == 2 
*Migrant respondents living in states that have NOT expanded Medicaid under Obamacare
replace obamacare = 1 if Q2 == 1 & (Q4_1 == 1 | Q4_9 == 1 | Q4_10 == 1 | Q4_16 == 1 | Q4_25 == 1 | Q4_33 == 1 | Q4_40 == 1 | Q4_41 == 1 | Q4_42 == 1 | Q4_43 == 1 | Q4_49 == 1 | Q4_50 == 1) 
*Alabama, Florida, Georgia, Kansas, Missouri, North Carolina, South Carolina, South Dakota, Tennessee, Texas, Wisconsin, Wyoming
*Migrant respondents living in US states where medicaid has been expanded
replace obamacare = 2 if obamacare == . 
label define obamacare 0 "Nonmigrant" 1 "States refusing" 2 "States expanded"
label values obamacare obamacare
label variable obamacare "States that have expanded coverage under Obamacare" 

**2b.b Welfare access 
*STATE ASSISTANCE (Borjas 1996) 
*Nonmigrant respondents
gen assistance_us = 0 if Q2 == 2 
*Migrant respondents living in less generous states 
replace assistance_us = 1 if Q2 == 1 & (Q4_1 == 1 | Q4_2 == 1 | Q4_3 == 1 |Q4_4 == 1 | Q4_12 == 1 | Q4_14 == 1 | Q4_15 == 1 | Q4_16  == 1 | Q4_17  == 1 | Q4_18 == 1 | Q4_22 == 1 | Q4_24 == 1 | Q4_26 == 1| Q4_28  == 1)
replace assistance_us = 1 if Q2 == 1 & (Q4_31 == 1 | Q4_33 == 1 | Q4_34 == 1 | Q4_36 == 1 |Q4_33 == 1 | Q4_41 == 1 | Q4_48 ==1 | Q4_50 == 1)
*Alabama, Alaska, Arizona, Arkansas, District of Columbia, Idaho, Indiana, Iowa, Kansas, Kentucky, Louisiana,
*Michigan, Mississippi, Montana, Nevada, New Mexico, North Carolina, North Dakota, Oklahoma, South Carolina, South Dakota, West Virginia, Wyoming   
*Migrant respondents living in more generous states  
replace assistance_us = 2 if assistance_us  == .
label define assistance_us 0 "Nonmigrant" 1 "Less generous" 2 "More generous", replace
label values assistance_us assistance_us
label variable assistance_us "Social assistance towards migrants" 
tab assistance_us, gen(assistance_us)

**2b.c E-Verify
*E-verify (mandatory to all employers, mandatory to public employers only, and no measures)
*Nonmigrant respondents
gen everify = 0 if Q2 == 2 
*Migrant respondents living in E-Verify states (public contractors / state employers)
*Idaho, Virginia, Florida, Indiana, Missouri, Nebraska, Oklahoma, Pennsylvania, Texas, Colorado, Louisiana, and Minnesota
replace everify = 2 if Q2 == 1 & (Q4_6 == 1 | Q4_9 == 1 | Q4_12 == 1 | Q4_14 == 1 | Q4_18 == 1 | Q4_25 == 1 |  Q4_23 == 1 | Q4_27 == 1 | Q4_36 == 1 | Q4_38 == 1 | Q4_43 == 1 | Q4_46 == 1)
*Migrant respondents living in E-Verify states (all employers)
*Alabama, Arizona, Georgia, Mississippi, North Carolina, South Carolina, Tennessee, Utah*
replace everify = 1 if Q2 == 1 &(Q4_1 ==1 | Q4_3 == 1 |  Q4_10 == 1 | Q4_24 == 1 |Q4_33 == 1 | Q4_40 == 1 |Q4_42 == 1 |Q4_44 == 1) 
*Migrant respondents living in no E-Verify states
replace everify = 3 if everify == .
label define everify 0 "Nonmigrant" 1 "All employers" 2 "Public employers and state contractors" 3 "no mandates", replace
label values everify everify 
label variable everify "E-Verify mandates" 
tab everify, gen(everify)

**2b.d Police-based measures
*Nonmigrant respondents
gen police_us = 0 if Q2 == 2  
*Migrant respondents living in anti-immigration states
*Arizona, Alabama, Indiana, Georgia, South Carolina, Utah
replace police_us = 1 if Q2 == 1 & (Q4_1 == 1 | Q4_3 == 1 |  Q4_10 == 1 | Q4_14 == 1 | Q4_40 == 1 |Q4_44 == 1)
*Migrant respondents living in liberal immigration states
replace police_us = 2 if police_us == .
label define police_us 0 "Nonmigrant" 2 "No immigration enforcement" 1 "Immigration enforcement" 
label values police_us police_us
label variable police_us "State immigration enforcement" 
tab police_us, gen(police_us) 

**2b.e Blue / red states
*Nonmigrant respondents
gen republican = 0 if Q2 == 2 
*Migrant respondents living in republican strongholds 
replace republican = 1 if Q2 == 1 & ( Q4_43 == 1 | Q4_1 == 1 | Q4_40 == 1 | Q4_36 == 1 | Q4_24 == 1 | Q4_44 == 1 | Q4_4 == 1 | Q4_27 == 1 | Q4_12 == 1 | Q4_41 == 1 | Q4_34 == 1 |  Q4_2 == 1 | Q4_50 == 1 | Q4_42 == 1 | Q4_25 == 1 | Q4_17 == 1 | Q4_18 == 1 | Q4_4 == 1 | Q4_48 == 1 | Q4_26 == 1 | Q4_33 == 1 | Q4_14 == 1 | Q4_10 == 1 | Q4_3 == 1)
*Texas, Alabama, South Carolina, Oklahoma, Mississippi, Utah, Kansas, Nebraska, Idaho, South Dakota, North Dakota, Alaska, Wyoming, Tennessee, Missouri, Kentucky, Louisiana, Arkansas, West Virginia, Montana, North Carolina, Indiana, Georgia, Arizona
*Migrant respondents living in non-Republican strongholds
replace republican = 2 if republican == .
label define republican 0 "Nonmigrant" 1 "Red states" 2 "Blue states", replace
label values republican republican
label variable republican "Blue states vs red states"
tab republican, gen(republican) 

**2b.f Tax structure(progresive taxes, flat, no income taxes)
*Nonmigrant respondents
gen tax_us = 0 if Q2 == 2
*Migrant respondents living in no income taxes states
*Alaska, Florida, Nevada, South Dakota, Tennessee, Texas, Wyoming
replace tax_us = 1 if Q2==1 &(Q4_2 ==1 | Q4_9 == 1 |  Q4_28 == 1 | Q4_41 == 1 | Q4_42 == 1 | Q4_43 == 1 | Q4_50 == 1)
*Migrant respondents living in flat income states
*Colorado, Illinois, Indiana, Kentucky, Massachusetts, Michigan, New Hampshire, North Carolina, Pennsylvania, Utah, Washington
replace tax_us = 2 if Q2==1 & (Q4_6 == 1 | Q4_13 == 1 | Q4_14 == 1 | Q4_17 == 1 | Q4_21 == 1 | Q4_22 == 1 |  Q4_29 == 1 | Q4_33 == 1 | Q4_38 == 1 | Q4_44 == 1 | Q4_47 == 1)
*Migrant respondents living in progressive  income states
replace tax_us = 3 if tax_us == . 
label define tax_us 0 "Nonmigrant" 3 "Progressive" 2 "Flat" 1 "No taxes", replace 
label values tax_us tax_us
label variable tax_us "Individual Income Tax Structures (flat/no taxes vs progressive)" 

*TAX STRUCTURE US (progresive taxes, flat/no income taxes)
*Nonmigrant respondents
gen tax_us2 = 0 if Q2 == 2
*Migrant respondents living in no income / flat rate taxes states
*Alaska, Florida, Nevada, South Dakota, Tennessee, Texas, Wyoming
replace tax_us2 = 1 if Q2==1 &(Q4_2 ==1 | Q4_9 == 1 |  Q4_28 == 1 | Q4_41 == 1 | Q4_42 == 1 | Q4_43 == 1 | Q4_50 == 1)
*Migrant respondents living in flat income states
*Colorado, Illinois, Indiana, Kentucky, Massachusetts, Michigan, New Hampshire, North Carolina, Pennsylvania, Utah, Washington
replace tax_us2 = 1 if Q2==1 & (Q4_6 == 1 | Q4_13 == 1 | Q4_14 == 1 | Q4_17 == 1 | Q4_21 == 1 | Q4_22 == 1 |  Q4_29 == 1 | Q4_33 == 1 | Q4_38 == 1 | Q4_44 == 1 | Q4_47 == 1)
*Migrant respondents living in progressive  income states
replace tax_us2 = 2 if tax_us2 == . 
label define tax_us2 0 "Nonmigrant" 2 "Progressive rates" 1 "Flat rates / No income taxes", replace 
label values tax_us2 tax_us2
label variable tax_us2 "Individual Income Tax Structures (flat/no taxes vs progressive)" 


**2b.g Drivers' licenses to undocumented migrants 
*Nonmigrant respondents
gen drivers = 0 if Q2 == 2
*Migrant respondents living in no income / flat rate taxes states
replace drivers = 2 if Q2==1 &(Q4_5 == 1 | Q4_6 == 1 | Q4_7 == 1 | Q4_8 == 1 | Q4_11 == 1 | Q4_13 == 1 | Q4_20 == 1 | Q4_28 == 1 | Q4_30 == 1 | Q4_31 == 1 | Q4_32 == 1 | Q4_37 == 1 | Q4_44 == 1 | Q4_45 == 1 | Q4_46 == 1 | Q4_47 == 1 )
*Migrant respondents living in states giving no driver licenses to undocumented migrants
replace drivers = 1 if drivers == . 
label define drivers 0 "Nonmigrant" 2 "Licenses" 1 "No licenses", replace 
label values drivers drivers
label variable drivers "Driving licenses to Undocumented"

**2b.h Covid deaths in the US  
gen covid_deaths = 0 if Q2 == 2
*Migrant respondents living in states with deaths above the national mean
replace covid_deaths = 2 if Q2==1 &(Q4_36 == 1 | Q4_1 == 1 |  Q4_48 == 1 | Q4_3 == 1 | Q4_17 == 1 | Q4_42 == 1 | Q4_10 == 1 | Q4_24 == 1 | Q4_9 == 1 | Q4_50 == 1 | Q4_40 == 1 | Q4_4 == 1 | Q4_26 == 1 | Q4_28 == 1 | Q4_25 == 1 |  Q4_43 == 1 | Q4_18 == 1 |  Q4_31 == 1  | Q4_38 == 1  | Q4_22 == 1 | Q4_12 == 1 | Q4_16 == 1)
*Migrant respondents living in states with deaths below the national mean
replace covid_deaths = 1 if covid_deaths == . 
label define covid_deaths 0 "Nonmigrant" 2 "Above the US national mean" 1 "Below the US national mean", replace 
label values covid_deaths covid_deaths
label variable covid_deaths "Covid deaths compared to US national mean"

**2b.i Migrants origin states - Mexico
tab Area, gen(state_mx) 
gen state_mx = 0
replace state_mx = 1 if ( state_mx1 ==1 |  state_mx8 == 1  | state_mx9 == 1|  state_mx10 == 1 | state_mx13 == 1 | state_mx15 == 1 | state_mx18 == 1 | state_mx24 == 1 | state_mx33 == 1)
replace state_mx = 2 if ( state_mx2 == 1 | state_mx3 == 1 | state_mx7 == 1 | state_mx6 == 1 | state_mx19 == 1 | state_mx25 == 1 | state_mx26 == 1 | state_mx28 == 1)
label variable state_mx "Historic migration states and border states of Mexico" 
label define state_mx 0 "Central and Southern States" 2 "Border states" 1 "Historic migration states", replace 
label values state_mx state_mx

**2b.j Migrants destination states - USA 
gen state_usa = 0
replace state_usa = 1 if ( Q4_3 == 1 | Q4_5 ==1 | Q4_31 ==1 | Q4_43 == 1)
label variable state_usa "US-Mx border states" 
label define state_usa 1 "Border states" 0 "Other states", replace 
label values state_usa state_usa


**********************************************
*2c. Demographic and Socioeconomic Variables*
**2c.a Age
**2c.b Gender
**2c.c Education 
**2c.c Income 
**2c.d Working status
**2c.e Public healthcare usage
**2c.f Religiousity 
**2c.h Economic anxieties 

**2c.a Age
tab age_range
label define age_range 1 "18-24 yrs" 2"25-34 yrs" 3"35-44 yrs" 4"45-54 yrs" 5"+55 yrs", modify
label values age_range age_range
tab age_range, gen(age_groups)
label variable age_groups1 "18-24 yrs"
label variable age_groups2 "25-34 yrs"
label variable age_groups3 "35-44 yrs"
label variable age_groups4 "45-54 yrs"
label variable age_groups5 "+55 yrs"

*Age recoded
recode age_range 4/5=4, gen(age_range2) 
label define age_range2 1 "18-24 yrs" 2"25-34 yrs" 3"35-44 yrs" 4"+45 yrs", modify
label values age_range2 age_range2

**2c.b Gender
sum gender
recode gender 2=0, gen(female)
label variable female "Female"
label define female 1 "female" 0 "male", modify
label values female female 

**2c.c Education 
recode education 1/2=1 3/4=2 5=3 6=4, gen(education_cat)
tab education_cat
label variable education_cat "education level"
label define education 1"elementary/middle school" 2"high school / technical college" 3"university" 4"postgraduate", modify
label values education education_cat
tab education_cat, gen(edlevel)
label variable edlevel1 "elementary/middle school"
label variable edlevel2 "high school / technical college"
label variable edlevel3 "university"
label variable edlevel4 "postgraduate"

recode education_cat 1/2 =0 3/4=1, gen(college_higher) 
label variable college_higher "college education or higher"

**2c.c Income 
*Poor under 10,000 pesos
*Middle class 10,000 - 40,000 pesos 
*Rich over 40,000 pesos
recode Q50 1/2=1 3/6=2 7/8=3, gen(income_level)
tab income_level
label variable income_level "Income level (ordinal)" 
label define income 1"poor" 2"middle-class" 3"rich", modify
label values income_level income
tab income_level, gen(income_cat)
label define income_level 1"poor" 2"middle" 3"rich", modify
label values income_level income_level
label variable income_cat1 "Poor"
label variable income_cat2 "Middle-class"
label variable income_cat3 "Rich"

**2c.d Working status
tab Q17
recode Q17 2=0, gen(employed)
label variable employed "Employed / Working"
label define employed 0"Unemployed" 1"Employed", modify 
label values employed employed

*Informal workers
recode Q19 0/1=0 2=1, gen(informal)
label variable informal "Informal worker"
label define informal 0"Noninformal" 1"Informal", modify
label values informal informal

**2c.e Public healthcare usage
recode Q37_10 1=1 2=0, gen(publichealth_usage)
label variable publichealth_usage "Have you used public healthcare services in the past year?"
label values publichealth_usage yesno

*Medical insurance
recode Q20 1=0 2=1 3=0, gen(publicinsurance)
label variable publicinsurance "Are medical expenses covered in your households with public healthcare insurance?"
label values publichealth_usage yesno

**2c.f Religiousity 
recode Q21 5=0 4= 1 3=2 2=3 1=4, gen(religiosity)
label variable religiosity "How often do you practice your religion?" 
label define religiosity 4 "At least once a day" 3 "At least once a week" 2"Several times a month" 1"Almost never" 0"Never", modify 
label values religiosity religiosity

**2c.g Ethnicity 
recode  Q24_2 2=0, gen(indigenous) 
label variable indigenous "Do you consider yourself indigenous?" 
label define indigenous 1 "indigenous" 0 "indigenous", modify
label values indigenous indigenous 

**2c.h Economic anxieties 
recode Q13_1 1/2=0 3=1 4/5=2, gen(country_economy)
recode Q13_2 1/2=0 3=1 4/5=2, gen(house_economy)
label variable country_economy  "Present economic situation in the country"
label variable house_economy "Present economic situation in the household"
label define economy 0 "Bad" 1"Neither" 2"Good", modify
label values country_economy economy
label values house_economy economy

*Evaluations of the economy
recode house_economy 0/1=0 2=1, gen(good_house_economy)
recode country_economy 0/1=0 2=1, gen(good_country_economy)
label define good_economy 0 "Bad/Neither" 1"Good", modify
label values good_country_economy good_economy
label values good_house_economy good_economy

*Income is enough
recode Q52 1=2 2=1 3/4=0, gen(enough_income)
label variable enough_income "Is the total household income good enough?"
label define enough_income 0 "Not enough" 1"Good enough" 2"Good enough and can save", modify
label values enough_income enough_income 
tab enough_income, gen(income_perceptions)
label variable income_perceptions1 "Income is not enough"
label variable income_perceptions2 "Income is good enough"
label variable income_perceptions3 "Income is good enough and can save"


*******************************
***2d. Tax related variables**
*******************************

*Tax compliance
gen tax_compliance =  Q32 
label variable tax_compliance "Share of Mexicans whom you think pay taxes"

*Tax process is difficult 
recode Q34_1 1/3= 0 4/5=1, gen(tax_difficult)
label variable tax_difficult "People avoid paying tax because the tax system is difficult"

*Tax rates are too high
recode Q34_2 1/3= 0 4/5=1, gen(tax_rates)
label variable tax_rates "People avoid paying tax because tax rates are too high"

*Tax avoidance in the society
recode Q34_3 1/3= 0 4/5=1, gen(tax_avoidance)
label variable tax_avoidance "People avoid paying tax because they know other people avoid taxes"

*Tax enforcement is poor
recode Q34_4 1/3= 0 4/5=1, gen(tax_enforcement)
label variable tax_enforcement "People avoid paying tax because the probability to be caught is low"

*Tax reciprocity is poor
recode Q34_5  1/3= 0 4/5=1, gen(tax_reciprocity) 
label variable tax_reciprocity "People avoid paying tax because they receive low quality goods from the state"

egen taxmorale_index = rowmean(tax_difficult-tax_reciprocity) 
 

********************************
*2e. Politics related variables*
********************************
*ideology 
recode Q38 0/33.33 = 0 33.34/66.65 = 1 66.66/100=2, gen (ideology)
label variable ideology "Self-ideological placement" 
label define ideology 0"Left" 1"Center" 2"Right", modify
label values ideology ideology
tab ideology, gen(self_placement)
label variable self_placement1 "Left" 
label variable self_placement2 "Center" 
label variable self_placement3 "Right" 

*party
recode Q40 1=1 2/4=0 5=1 6=1 7=0 102= 0 103=0, gen(incumbent)
label variable incumbent "Supports incumbent parties" 
recode Q40 1=0 2/4=1 5=0 6=0 7=1 102= 1 103=0, gen(opposition)
label variable opposition "Supports opposition parties" 
recode Q40 1=0 2/4=0 5=0 6=0 7=0 102= 0 103=1, gen(noparty)
label variable noparty "Does not identify with any party" 
recode Q40 1=1 2/4=2 5=1 6=1 7=2 102= 2 103=3, gen(party_id)
label define party_id 1"incumbent" 2"opposition" 3"no party" 
label values party_id party_id 

*Voted 
recode Q37_1 2=0, gen(voted)
label variable voted "Voted in the last federal election" 

*Referendum 
recode Q37_2 2=0, gen(referendum)
label variable referendum "Participated in the presidential referendum" 


********************************
*2f. Security related variables*
********************************

*Safety perceptions
recode Q23_1 1/2=1 3/5=0, gen(unsafe_neigh)
label variable unsafe_neigh "Feeling unsafe in the neighbourhood" 
recode Q23_2 1/2=1 3/5=0, gen(unsafe_state)
label variable unsafe_state "Feeling unsafe in the state" 
recode Q23_3 1/2=1 3/5=0, gen(unsafe_country)
label variable unsafe_country "Feeling unsafe in the country" 

*Security evaluations (present)
recode Q13_3 1/2=1 3/5=0, gen(seceval_neigh)
label variable seceval_neigh "Bad security situation in neighbourhood" 
recode Q13_4 1/2=1 3/5=0, gen(seceval_country)
label variable seceval_country "Bad security situation in country" 

*Security evaluations (retospective)
recode Q14_4 1/2=1 3/5=0, gen(pastseceval_neigh)
label variable seceval_neigh "Worse security situation in neighbourhood" 
recode Q14_3 1/2=1 3/5=0, gen(pastseceval_country)
label variable pastseceval_country "Worse security situation in country" 

*Own justice in neighbourhood 
recode Q28_5 1/2=0 3/5=1, gen(ownjustice_neigh)
label variable ownjustice_neigh "Likely that neighbours take justice in their own hands" 

*Vigilantes in neighbourhood 
recode Q43_1 2=0, gen(vigilantes_neigh)
label variable vigilantes_neigh "Neighbours organised into self-protection groups" 
label define vigilantes_neigh 1 "Watchgroups in neighborhood" 0"No watchgroups in neighbourhood", modify
label values vigilantes_neigh vigilantes_neigh

*Trust in the police
recode Q30_1 1/3=0 4/5=1, gen(trafficpolice)
label variable trafficpolice "Easy to bribe a traffic officer" 
recode Q30_2 1/3=0 4/5=1, gen(localpolice)
label variable localpolice "Easy to bribe a local police officer" 
recode Q30_3 1/3=0 4/5=1, gen(federalpolice)
label variable federalpolice "Easy to bribe a federal police officer"
egen distrust_police = rowtotal(trafficpolice-federalpolice)
label variable distrust_police "Distrust in police" 

*Crime victim 
recode Q41 2=0, gen(crime_victim) 
label variable crime_victim "Victim of a crime" 

*Violent crime victim 
recode Q42 0=0 1/2=1 3=2, gen(violence_victim) 
label define violence_victim 0"nonvictim" 1"violent crime victim" 2"nonviolent crime victim", modify
label variable violence_victim "Victim of violence" 

tab violence_victim, gen(victim)
label variable victim1 "nonvictim"
label variable victim2 "violent crime victim"
label variable victim3 "nonviolent crime victim" 

*Extorsion victim
recode Q43_4 2=0, gen(extorsion_victim)
label variable extorsion_victim "Changed telephone number due to extorsion" 

*Fear of crime (changed behaviour) 
recode  Q43_2 2=0, gen(crime_fear) 
label variable crime_fear "Changed behaviour because of fear of crime" 
label define crime_fear 1 "Changed behaviour because of fear of crime" 0"No changed behaviour because of fear of crime", modify
label values crime_fear crime_fear

*Fear of crime (security measures)
recode  Q43_3 2=0, gen(crime_expenses) 
label variable crime_expenses "Security protection measures because of fear of crime" 

*Has considered moving to another neighbourhood due to fear of crime 
recode  Q43_5 2=0, gen(crime_moving) 
label variable crime_moving "Has considered moving neighbourhood to due to fear of crime" 

*Has considered emigrating due to fear of crime 
recode  Q43_5 2=0, gen(crime_migration) 
label variable crime_migration "Has considered emigrating due to fear of crime" 

*Reporting crime (likely)
recode Q28_3 1/3=0 4/5=1, gen(report_crime)
label variable report_crime "Likely to report a minor crime" 
recode Q28_4 1/3=0 4/5=1, gen(report_seriouscrime)
label variable report_seriouscrime "Likely to report a major crime" 

*Reasons why people do not report crime 
recode  Q34_6 1/3=0 4/5=1, gen(reporting_difficult)
label variable reporting_difficult "Reporting a crime is difficult" 
recode  Q34_7 1/3=0 4/5=1, gen(reporting_useless)
label variable  reporting_useless "Reporting a crime is useless" 
recode  Q34_8 1/3=0 4/5=1, gen(reporting_retaliation)
label variable reporting_retaliation "Reporting a crime can lead to retaliation from criminals" 

******************************************************************
*State violence 

*Knows someone who has suffer violence on the way to the US
recode Q47_1 2=0, gen(violence_US)
label variable violence_US "Someone who has suffered violence or abuses on their way to the US?"

*Knows someone who has been victim of police abuse 
recode Q47_2 2=0, gen(police_abuse)
label variable police_abuse "Someone who has suffered from physical or verbal abuse by state officers?"
label define police_abuse 1 "Knows of state abuse" 0"Doesn't know of state abuse", modify
label values police_abuse police_abuse

*Knows someone who has paid a bribe to security officers
recode Q47_3 2=0, gen(police_bribe)
label variable police_bribe "Someone who has paid a bribe to a police officer or a public prosecutor?"
label define police_bribe 1 "Paid bribe to police officer" 0"Did not pay bribe", modify
label values police_bribe police_bribe

*Know someone who has paid a bribe to a goverment officer
recode Q47_4 2=0, gen(officer_bribe)
label variable officer_bribe "Someone who has paid a bribe to a government officer?"

**Know someone who has paid a bribe
egen bribe = rowtotal(police_bribe-officer_bribe)
recode bribe 0=0 1/2=1
label variable bribe "Someone who has paid a bribe"

*******************************************************************
*2g. COVID
recode Q44 2=0, gen(covid_infection)
label variable covid_infection "Infected with Covid-19"
recode Q45 1=1 2/4=0, gen(covid_vaccine)
label variable covid_vaccine "Vaccinated against Covid-19"



save "Data\Data ready E1.dta", replace 
